home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
CRS
/
crs05.d81
/
evsbasic.arc
/
RECORD#.DMO
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2009-10-10
|
2KB
|
93 lines
10 (null) 0
20 PRINT" THIS IS A SIMPLE PROGRAM WHICH CREATES"
30 PRINT" A SMALL RELATIVE DISK FILE, WRITES"
40 PRINT" SOME MEANINGLESS DATA TO IT, AND READS"
50 PRINT" IT BACK ON DEMAND. IT IS INTENDED"
60 PRINT" ONLY TO DEMONSTRATE HOW THE PROCEDURE"
70 PRINT" WORKS, AND IS ONLY A SKELETON PROGRAM."
80 PRINT" PRESS ANY KEY TO BEGIN."
90 :
100 A$=(null)(1)
110 :
200 RL=30: REM * RECORD LENGTH
205 RN=6 : REM * #RECORDS
210 :
300 PRINT"[147] MAKING SOME RECORDS"
305 GOSUB 1005
310 PRINT" OPENING A RELATIVE FILE"
315 (null)"S0:RELTESTFILE"
320 OPEN 2,8,3,"0:RELTESTFILE,L,"+CHR$(RL)
325 GOSUB 905
330 PRINT" CREATING ";RN;"EMPTY RECORDS"
335 (null)2,RN
340 GOSUB 905
345 PRINT#2,"LAST RECORD"
350 GOSUB 905
355 PRINT" WRITING ";RN;"RECORDS"
360 FOR I=1 TO RN
365 (null)2,I
370 PRINT#2,RC$(I)
375 NEXT
380 GOSUB 905
385 PRINT" CLOSING FILE"
390 CLOSE 2
395 GOSUB 905
400 :
500 PRINT" PRESS ANY KEY TO RE-OPEN"
505 PRINT" FILE AND RECOVER RECORDS"
510 A$=(null)(1)
515 :
600 (null)
605 PRINT" RE-OPENING FILE"
610 OPEN 2,8,5,"RELTESTFILE"
615 GOSUB 905
620 (null)
625 INPUT" RECORD# TO RECOVER ('0' TO QUIT)";A$
630 A=INT(VAL(A$))
635 IFA<0ORA>RNTHEN625
640 IFA=0THEN(null)
645 :
700 REM *RECOVER RECORD
705 (null)2,A
710 A$=(null)(RL,#2)
715 PRINT" RECORD IS: ";A$
720 (null)
725 :
800 REM *QUIT
805 CLOSE2
810 :
815 PRINT" NOTE THE DOUBLE-SPACING OF RECOVERED"
820 PRINT" RECORDS WAS CAUSED BECAUSE THE LAST"
825 PRINT" CHARACTER OF EACH RECORD WAS A"
830 PRINT" CARRIAGE RETURN. -PRINT#- ADDED THIS"
835 PRINT" WHEN THE RECORD WAS FIRST WRITTEN."
840 PRINT" FOR THIS REASON RECORD LENGTHS ARE"
845 PRINT" NORMALLY ONE CHARACTER LONGER THAN THE"
850 PRINT" NUMBER OF CHARACTERS OF INFORMATION"
855 PRINT" IN THE RECORD."
860 :
865 END
870 :
900 REM *CHECK DISK ERROR STATUS
905 PRINT" DISK STATUS= ";(null)
910 IF (null)>20 AND (null)<>50 THEN CLOSE 2: PRINT: PRINT" UNRECOVERABLE ERROR": END
915 RETURN
920 :
1000 REM *MAKE SOME RECORDS
1005 FOR I=1 TO RN
1010 READ A$,B$
1015 C$=(null)(RL-1," ")
1020 C$=(null)(1,C$,A$)
1025 C$=(null)(15,C$,B$)
1030 RC$(I)=C$
1035 NEXT
1040 RETURN
1045 :
1100 REM *SOME MEANINGLESS DATA
1105 DATA MARY,34J
1110 DATA LARRY,91A
1115 DATA SHERRY,75P
1120 DATA BARRY,06R
1125 DATA TERRY,82M
1130 DATA GARY,16Y